package demo.practice.bit;

public class P476 {
    public static void main(String[] args) {
        //System.out.println(!1);
    }

    public int findComplement(int num) {
        int res=0;
        int i=0;
        while (num>0){
            int bit= num&1;
            if(bit==0){
                res ^= (1<<i);
            }
            num>>=1;
            i++;
        }
        return res;
    }
}
